<template>
  <div class="register">
    <h2>注册</h2>
    <div>
    	<p><span>用户名:</span><input v-model="userName" placeholder="请输入用户名" /></p>
    	<p><span>密码:</span><input v-model="passWord" placeholder="请输入密码" /></p>
    </div>
	<button @click = 'register'>注册</button>
   
  </div>
</template>

<script>
import axios from 'axios'  //引入
//import router from '../router';//路由
export default {
  name: 'register',
  data () {
    return {
      userName:'',
      passWord:''
    }
  },
  methods:{
  register(){
  	this.$axios.get('/users/register',{params:{'userName': this.userName,'passWord':this.passWord}}).then(res=>{
  		console.log(res)
		if(res.data.result.code==200){
			alert(res.data.result.msg);
			this.$router.push({path: '/login'});
		}else{
			alert(res.data.result.msg);
		}
  	}).catch(err=>{
  		console.log(err);
  	})
  	 
  }
  }
 
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
